package com.lucy.property.module.fee;

import com.lucy.common.core.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.*;
import org.hibernate.Hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author kindear
 * 收费项 -- 如物业费规则
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "fee_item")
@ApiModel(value = "收费项对象")
public class FeeItem extends BaseEntity implements Serializable {
    /** 收费项分类 */
    @Column(name = "fee_type")
    private String feeType;

    /** 收费项目名 */
    @Column(name = "fee_name")
    private String feeName;

    /** 单价 */
    @Column(name = "price")
    private Double price;

    /** 固定费用 **/
    @Column(name = "fixed_fee")
    private Double fixedFee;

    /** 费用周期(月为单位) */
    @Column(name = "period")
    private Integer period;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        FeeItem item = (FeeItem) o;
        return getId() != null && Objects.equals(getId(), item.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
